#pragma once

#include "Game/Scene/Entity.h"
#include "Render/Buffer/VertexBuffer.h"
#include "Render/Buffer/IndexBuffer.h"

enum RayObjType
{
	LightType = 0,
	DiffuseType = 1,
	ReflectType = 2
};

struct RayVertex
{
	glm::vec3 pos;
	glm::vec3 normal;
	glm::vec2 texC;
};

struct RayMaterial
{
	glm::vec3 ambient;
	int32 textureId;
};

struct RayObjDesc
{
	int32 type;
	uint64 vertexAddress;
	uint64 indexAddress;
	uint64 materialAddress;
};


class LocalEntity : public Entity
{
public:

	LocalEntity(entt::entity handle, GameScene* gameScene) : Entity(handle, gameScene) {};

	void SetColor(glm::vec4 color);

	void SetTypeAndMaterial(RayObjType objType, RayMaterial rayMaterial);

protected:

	virtual void ReleaseResource() override;

	virtual void OnTick(float deltaTime) override;

public:

	// For Local Scene
	glm::vec4 mColor;

	DescriptorMask mDescriptorMask;

	RefCountPtr<RHIBuffer> mUboBuffer;



	// For Ray Tracing
	RefCountPtr<VertexBuffer> mVertexBuffer;

	RefCountPtr<IndexBuffer> mIndexBuffer;

	RefCountPtr<RHIBuffer> mTransformBuffer;

	RayMaterial mRayMaterial;

	RefCountPtr<RHIBuffer> mMaterialBuffer;

	RayObjType mObjType;
};